home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / mee / vbdao / visdata / join.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  4.6 KB  |  162 lines

  1. VERSION 2.00
  2. Begin Form fJoin 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Join Tables"
  6.    ClientHeight    =   1935
  7.    ClientLeft      =   3510
  8.    ClientTop       =   1935
  9.    ClientWidth     =   5835
  10.    ControlBox      =   0   'False
  11.    Height          =   2340
  12.    Left            =   3450
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   1935
  17.    ScaleWidth      =   5835
  18.    Top             =   1590
  19.    Width           =   5955
  20.    Begin CommandButton ClearJoinsButton 
  21.       BackColor       =   &H00C0C0C0&
  22.       Caption         =   "C&lear All Joins"
  23.       Height          =   372
  24.       Left            =   2040
  25.       TabIndex        =   7
  26.       Top             =   1480
  27.       Width           =   1812
  28.    End
  29.    Begin CommandButton CloseButton 
  30.       BackColor       =   &H00C0C0C0&
  31.       Cancel          =   -1  'True
  32.       Caption         =   "&Close"
  33.       Height          =   372
  34.       Left            =   3960
  35.       TabIndex        =   6
  36.       Top             =   1480
  37.       Width           =   1812
  38.    End
  39.    Begin ListBox cFieldList2 
  40.       BackColor       =   &H00FFFFFF&
  41.       Height          =   1200
  42.       Left            =   3960
  43.       TabIndex        =   4
  44.       Tag             =   "OLS"
  45.       Top             =   240
  46.       Width           =   1815
  47.    End
  48.    Begin ListBox cFieldList1 
  49.       BackColor       =   &H00FFFFFF&
  50.       Height          =   1200
  51.       Left            =   2040
  52.       TabIndex        =   3
  53.       Tag             =   "OLS"
  54.       Top             =   240
  55.       Width           =   1815
  56.    End
  57.    Begin CommandButton AddJoinButton 
  58.       BackColor       =   &H00C0C0C0&
  59.       Caption         =   "&Add Join to Query"
  60.       Enabled         =   0   'False
  61.       Height          =   372
  62.       Left            =   120
  63.       TabIndex        =   1
  64.       Top             =   1480
  65.       Width           =   1812
  66.    End
  67.    Begin ListBox cTableList 
  68.       BackColor       =   &H00FFFFFF&
  69.       Height          =   1200
  70.       Left            =   120
  71.       MultiSelect     =   1  'Simple
  72.       TabIndex        =   0
  73.       Tag             =   "OLS"
  74.       Top             =   240
  75.       Width           =   1815
  76.    End
  77.    Begin Label FieldsLabel 
  78.       Alignment       =   2  'Center
  79.       BackColor       =   &H00C0C0C0&
  80.       Caption         =   "Select Fields to Join Selected Tables on:"
  81.       Height          =   192
  82.       Left            =   2040
  83.       TabIndex        =   5
  84.       Top             =   0
  85.       Width           =   3732
  86.    End
  87.    Begin Label TableListLabel 
  88.       BackColor       =   &H00C0C0C0&
  89.       Caption         =   "Select Table Pair:"
  90.       Height          =   192
  91.       Left            =   120
  92.       TabIndex        =   2
  93.       Top             =   0
  94.       Width           =   1812
  95.    End
  96. Option Explicit
  97. Dim FTbl1 As String
  98. Dim FTbl2 As String
  99. Sub AddJoinButton_Click ()
  100.   Dim i As Integer
  101.   fQuery.cJoinFields.AddItem FTbl1 & "." & cFieldList1 & "=" & FTbl2 & "." & cFieldList2
  102.   For i = 0 To cTableList.ListCount - 1
  103.     cTableList.Selected(i) = False
  104.   Next
  105. End Sub
  106. Sub cFieldList1_Click ()
  107.   If Len(cFieldList2) > 0 Then
  108.     AddJoinButton.Enabled = True
  109.   End If
  110. End Sub
  111. Sub cFieldList2_Click ()
  112.   If Len(cFieldList1) > 0 Then
  113.     AddJoinButton.Enabled = True
  114.   End If
  115. End Sub
  116. Sub ClearJoinsButton_Click ()
  117.   fQuery.cJoinFields.Clear
  118. End Sub
  119. Sub CloseButton_Click ()
  120.   Unload Me
  121. End Sub
  122. Sub cTableList_Click ()
  123.   Dim i As Integer
  124.   Dim t As TableDef
  125.   FTbl1 = NULL_STR
  126.   FTbl2 = NULL_STR
  127.   cFieldList1.Clear
  128.   cFieldList2.Clear
  129.   For i = 0 To cTableList.ListCount - 1
  130.     If cTableList.Selected(i) Then
  131.       If Len(FTbl1) = 0 Then
  132.         FTbl1 = cTableList.List(i)
  133.       Else
  134.         FTbl2 = cTableList.List(i)
  135.         Exit For
  136.       End If
  137.     End If
  138.   Next
  139.   If Len(FTbl2) = 0 Then Exit Sub   'only one table selected
  140.   Set t = gCurrentDB.TableDefs(FTbl1)
  141.   For i = 0 To t.Fields.Count - 1
  142.     cFieldList1.AddItem t.Fields(i).Name
  143.   Next
  144.   Set t = gCurrentDB.TableDefs(FTbl2)
  145.   For i = 0 To t.Fields.Count - 1
  146.     cFieldList2.AddItem t.Fields(i).Name
  147.   Next
  148. End Sub
  149. Sub Form_Load ()
  150.   Dim i As Integer
  151.   For i = 0 To fQuery.cTableList.ListCount - 1
  152.     If fQuery.cTableList.Selected(i) Then
  153.       cTableList.AddItem fQuery.cTableList.List(i)
  154.     End If
  155.   Next
  156.   Top = VDMDI.Top + fQuery.Top + fQuery.cCriteria.Top + 1300
  157.   Left = fQuery.Left + 1500
  158. End Sub
  159. Sub Form_Paint ()
  160.   Outlines Me
  161. End Sub
  162.